﻿using Business.WPF;
using DataAccess.Exceptions;
using Presenters.WPF.Views;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Presenters.WPF
{
    public class ClassroomObjectPresenter
    {
        public IClassroomObject view { get; set; }


        public ClassroomObjectPresenter(IClassroomObject view)
        {
            this.view = view;            
        }

        public void SubmitNewClassroom()
        {
            try
            {
                ClassroomObjectManager ns = new ClassroomObjectManager();
                ns.newClassroom(this.view.code, this.view.capacity, this.view.type, this.view.status);
                this.view.message = "Se agregó correctamente el aula: " + this.view.code;
            }
            catch (ValidationException v_ex)
            {
                this.view.message = v_ex.Message;
            }
            catch (BusinessException b_ex)
            {
                this.view.message = b_ex.Message;
            }
            catch (Exception ex)
            {
                this.view.message = "Error -> " + ex.Message;
            }
        }

        public void SubmitModifyClassroom()
        {
            try
            {
                ClassroomObjectManager ns = new ClassroomObjectManager();
                ns.modifyClassroom(this.view.code, this.view.capacity, this.view.type, this.view.status);
                this.view.message = "Se modificó correctamente el aula: " + this.view.code;
            }
            catch (ValidationException v_ex)
            {
                this.view.message = v_ex.Message;
            }
            catch (BusinessException b_ex)
            {
                this.view.message = b_ex.Message;
            }
            catch (Exception ex)
            {
                this.view.message = "Error -> " + ex.Message;
            }
        }
    }
}
